import { IInitUSerState, IAction } from "./types"
import { LOGIN, LOGOUT ,AddMenuAction} from "./constants"

const initState: IInitUSerState = {
    user: {},
    menu:[],
}

const userReducer = (state = initState, action: IAction): IInitUSerState => {
    switch(action.type) {
        case LOGIN: {
            return {...state, user:  action.user}
        }
        case LOGOUT: {
            return {...state, user: {}}
        }
        case AddMenuAction:{
            return {...state, menu: action.menu}
        }
        default: {
            return { ...state }
        }
    }
}

export default userReducer
